<template>
	<view style="padding: 25rpx;">
        <view class="ni" v-for="(item,index) in list">
           <view style="display: flex;align-items: center; justify-content: space-between;padding: 20rpx; color: #555;">
               <view style="display: flex;align-items: center;">
                   <image style="width: 60rpx;height: 60rpx;border-radius: 15rpx;margin-right:20rpx ;" :src="item.sender.avatar"></image>
                   <text>{{item.sender.nickname}}</text>
               </view>
               <view style="font-size: 25rpx;">{{timestampToTime(item.timestamp)}}</view>
           </view>
           <view style="font-size: 26rpx;color: #777;display: flex;align-items: center;">收藏内容：
                <view v-if="item.type == 'text'">{{item.message.content}}</view>
                <image style="border-radius: 15rpx;width: 200rpx;" mode="widthFix" v-else :src="item.message.content"></image>
           </view>
        </view>
	</view>
</template>

<script>
    
    
	export default {
		data() {
			return {
				list:[]
			}
		},
        onLoad() {
          this.getShoucang()  
        },
		methods: {
			getShoucang(){
                const cachedFavorites = uni.getStorageSync('favorites');
                console.log('dadadadada',cachedFavorites)
                this.list = JSON.parse(cachedFavorites)
            },
            timestampToTime(timestamp) {
                var date = new Date(timestamp * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
                var Y = date.getFullYear();
                var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
                var D = date.getDate();
                var h = date.getHours();
                var m = date.getMinutes();
                var s = date.getSeconds();
                if (D < 10) D = '0' + D;
                if (h < 10) h = '0' + h;
                if (m < 10) m = '0' + m;
                if (s < 10) s = '0' + s;
                return Y + '-' + M + '-' + D + ' ' + h + ':' + m + ':' + s;
            }
		}
	}
</script>

<style scoped>
page{
    background: #eeeeee;
}
</style>
